home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 06 - 1990 / 06.05 May 90 / PrintWindow Code / About.c next >
Encoding:
C/C++ Source or Header  |  1990-03-01  |  3.6 KB  |  152 lines  |  [TEXT/KAHL]

  1. /********************************
  2. File: About.c
  3. ********************************/
  4. /**********************
  5. Include files
  6. ***********************/
  7. #include "String.h"
  8.  
  9. /**********************
  10. Constants
  11. ***********************/
  12. #define    TRUE    1
  13. #define    FALSE    0
  14. #define    NIL        0
  15. #define    I_OK    1
  16. #define    I_Print    2
  17. #define I_User    7
  18. #define AboutID    2
  19. #define TestID    1
  20.  
  21. /**********************
  22. Globals
  23. ***********************/
  24. static    char    ExitDialog;
  25. static    DialogPtr    GetSelection;
  26. Rect    tempRect;
  27. short    DType;
  28. Handle    DItem;
  29. Str255    sTemp;
  30. short    itemHit;
  31. DialogPeek    TheDialogPtr;
  32.  
  33. /**********************
  34. Refresh_Dialog(GetSelection) bolds OK button
  35. ***********************/
  36. static void  Refresh_Dialog(GetSelection)
  37. DialogPtr    GetSelection;
  38. { /* Refresh_Dialog() */
  39. GetDItem(GetSelection,I_OK, &DType, &DItem, &tempRect);
  40.  
  41. PenSize(3, 3);
  42. InsetRect(&tempRect, -4, -4);
  43.  
  44. FrameRoundRect(&tempRect, 16, 16);
  45. PenSize(1, 1);
  46. } /* Refresh_Dialog() */
  47.  
  48. /**********************
  49. UpDate_AboutDialog() for printing
  50. ***********************/
  51. UpDate_AboutDialog(theWindow)
  52. WindowPtr theWindow;
  53. { /* UpDate_AboutDialog() */
  54. if (theWindow == (WindowPtr) GetSelection) { /* check if "About" dialog */
  55.     PrintDialog((DialogPeek) GetSelection, "\p", "\p", "\p", "\p"); /* print it */
  56.     Refresh_Dialog(GetSelection); /* call any user-drawn stuff */
  57.     }
  58. } /* UpDate_AboutDialog() */
  59.  
  60. /**********************
  61. D_About() handles "About" dialog
  62. ***********************/
  63. void   D_About()
  64. { /* D_About() */
  65. /* Get Dialog */
  66. GetSelection = GetNewDialog(AboutID, NIL, (WindowPtr)-1);
  67. ShowWindow(GetSelection);
  68. SelectWindow(GetSelection);
  69. SetPort(GetSelection);
  70.  
  71. /* set it up */
  72. Refresh_Dialog(GetSelection);
  73. ExitDialog = FALSE;
  74.      
  75. do { /* Handle dialog until done */
  76.     ModalDialog(NIL, &itemHit);
  77.     GetDItem(GetSelection, itemHit, &DType, &DItem, &tempRect);
  78.          
  79.     if (itemHit == I_OK)
  80.         ExitDialog =TRUE; /* flag for exit */
  81.          
  82.     if (itemHit == I_Print)
  83.         PrintWindow((WindowPtr) GetSelection); /* print dialog */
  84.     
  85.     Refresh_Dialog(GetSelection);    
  86.     } while (ExitDialog == FALSE);
  87. DisposDialog(GetSelection);
  88. } /* D_About() */
  89.  
  90. /**********************
  91. myUserItem() proc for user item
  92. ***********************/
  93. pascal void myUserItem(w, i)
  94. WindowPtr w;
  95. int i;
  96. { /* myUserItem() */
  97. int t;
  98. Handle h;
  99. Rect r;
  100.  
  101. GetDItem(GetSelection, I_User, &t, &h, &r);
  102. FrameRect(&r); /* Draw something */
  103. } /* myUserItem() */
  104.  
  105. /**********************
  106. UpDate_TestDialog() for printing
  107. ***********************/
  108. UpDate_TestDialog(theWindow)
  109. WindowPtr theWindow;
  110. { /* UpDate_TestDialog() */
  111. if (theWindow == (WindowPtr) GetSelection) { /* check if "Test" dialog */
  112.     PrintDialog((DialogPeek) GetSelection, "\p", "\p", "\p", "\p"); /* print it */
  113.     Refresh_Dialog(GetSelection); /* call any user-drawn stuff */
  114.     }
  115. } /* UpDate_TestDialog() */
  116.  
  117. /**********************
  118. Refresh_Dialog(GetSelection) bolds OK button
  119. ***********************/
  120. void   D_TestDialog()
  121. { /* D_TestDialog() */
  122. /* Get Dialog */
  123. GetSelection = GetNewDialog(TestID, NIL, (WindowPtr)-1);
  124. ShowWindow(GetSelection);
  125. SelectWindow(GetSelection);
  126. SetPort(GetSelection);
  127.  
  128. /* set it up */
  129. GetDItem(GetSelection, I_User, &DType, &DItem, &tempRect); /* set up user-item */
  130. SetDItem(GetSelection, I_User, DType, myUserItem, &tempRect);
  131.  
  132. Refresh_Dialog(GetSelection);
  133. myUserItem((WindowPtr) GetSelection, I_User);
  134. ExitDialog = FALSE;
  135.  
  136. do { /* Handle dialog until done */
  137.     ModalDialog(NIL, &itemHit);
  138.     GetDItem(GetSelection, itemHit, &DType, &DItem, &tempRect);
  139.      
  140.     if (itemHit == I_OK)
  141.         ExitDialog =TRUE; /* flag for exit */
  142.     
  143.     if (itemHit == I_Print)
  144.         PrintWindow((WindowPtr) GetSelection); /* print it */
  145.          
  146.     Refresh_Dialog(GetSelection);
  147.      
  148.     } while (ExitDialog == FALSE);
  149. DisposDialog(GetSelection);
  150. } /* D_TestDialog() */
  151.  
  152.